cd /d %~dp0


set pwd=%cd%
set binpath=%pwd%\launch2.bat
echo %binpath%

set servicename=launch2

sc stop %servicename%
ping 127.0.0.1  -n  3  >nul
sc delete %servicename%

if "%1" == "uninstall" goto end

if "%PROCESSOR_ARCHITECTURE%" == "x86" if "%PROCESSOR_ARCHITEW6432%" == "" goto os32

nssm64 install %servicename% "%binpath%"
goto start_service

:os32
nssm install %servicename% "%binpath%"

:start_service
sc config %servicename% start= Auto
rem sc config %servicename% DisplayName= "%servicename%"
sc start %servicename%

:end